import time

from PySide6.QtWidgets import QApplication, QMessageBox
from PySide6.QtUiTools import QUiLoader

# 在QApplication之前先实例化
uiLoader = QUiLoader()

class Stats:

    def __init__(self):
        # 再加载界面
        self.ui = uiLoader.load('ui/ui_qcombobox.ui')
        self.ui.comboBox.addItem('1')
        self.ui.comboBox.addItem('2')
        self.ui.comboBox.currentIndexChanged.connect(self.demo_1)
        self.ui.pushButton.clicked.connect(self.demo_2)
        self.ui.pushButton.setText("清空")



    def demo_1(self):
        self.ui.label.setText(f"选取了：{self.ui.comboBox.currentText()}")

    def demo_2(self):
        self.ui.comboBox.clear()


app = QApplication([])
stats = Stats()
stats.ui.show()
app.exec() # PySide6 是 exec 而不是 exec_